package song.springcloud.controller;

import com.song.springcloud.pojo.User;
import com.song.springcloud.service.UserClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
public class UserConsumerController {

    @Autowired
    private UserClientService userClientService;

    @RequestMapping("/consumer81/user/get/{id}")
    @ResponseBody
    public User get(@PathVariable("id") Long id) {
        return userClientService.queryById(id);
    }

    //http://localhost:81/consumer81/user/list
    @RequestMapping("/consumer81/user/list")
    @ResponseBody
    public List<User> list() {
        System.out.println("进入了list查询");
        return userClientService.queryAll();
    }

    @RequestMapping("/consumer81/user/add")
    @ResponseBody
    public Boolean add(User user) {
        return userClientService.addUser(user);
    }

}
